
public class StudentAdmin3 {
	String[] names = new String[30];

	public void addName(String name){
		for (int i = 0; i < names.length; i++) {
			if(names[i]==null){
				names[i] = name;
				break;
			}
		}
	}
	
	public void showAllName(){
		for (int i = 0; i < names.length; i++) {
			if(names[i]!=null){
				System.out.println(names[i]);
			}
		}
	}
	
	public int searchName(String name){
		for (int i = 0; i < names.length; i++) {
			if(names[i].equals(name)){
				return i;
			}
		}
		
		return -1;
	}
	
	public boolean modifyName(String oldName,String newName){
		int index = searchName(oldName);
		
		if(index==-1){
			return false;
		}else{
			names[index] = newName;
			return true;
		}
	}
	
	public static void main(String[] args) {
		StudentAdmin3 sa = new StudentAdmin3();
		sa.addName("zhangsan");
		sa.addName("lisi");
		sa.addName("wangwu");

		sa.modifyName("zhangsan", "sange");
		
		sa.showAllName();
	}
}













